﻿<Window xmlns:xctk="http://schemas.xceed.com/wpf/xaml/toolkit"  x:Class="XEasyFileSearch.MainWindow"
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
   
       xmlns:tke ="clr-namespace:Xceed.Wpf.Toolkit;assembly=WPFToolkit.Extended"
        Title="XEasyFileSearcher" Height="600" Width="800"
        xmlns:my="clr-namespace:System.Windows.Controls;assembly=System.Windows.Controls.Input.Toolkit"
        FontSize="20" WindowStartupLocation="CenterScreen"
       xmlns:cmd="clr-namespace:GalaSoft.MvvmLight.Command;assembly=GalaSoft.MvvmLight.Extras.WPF4"
         xmlns:i="clr-namespace:System.Windows.Interactivity;assembly=System.Windows.Interactivity"
        xmlns:dg ="http://schemas.xceed.com/wpf/xaml/datagrid"
        xmlns:conv ="clr-namespace:XEasyFileSearch">
    <i:Interaction.Triggers>
        <i:EventTrigger EventName="Loaded">
            <cmd:EventToCommand Command="{Binding Source={StaticResource Locator}, Path=Main.InitCommand}" />
        </i:EventTrigger>
    </i:Interaction.Triggers>
    <xctk:BusyIndicator 
            IsBusy="{Binding Source={StaticResource Locator}, Path=Main.IsBusy}" 
            BusyContent="{Binding Source={StaticResource Locator}, Path=Main.BusyContent}"  >
        <Grid>
            <Grid.Resources >
                <conv:DisplayFileNameConverter x:Key="_DisplayFileNameConverter" />
                <conv:IconDisplayConverter x:Key="_IconDisplayConverter" />
            </Grid.Resources>
            <Grid.RowDefinitions>
                <RowDefinition Height="27" />
                <RowDefinition Height="50" />
                <RowDefinition  />
                <RowDefinition Height="27"  />
            </Grid.RowDefinitions>
            <Menu Grid.Row="0" >
                <MenuItem Header="Fájl" >
                    <MenuItem Header="Beállítás" Command="{Binding Source={StaticResource Locator}, Path=Main.ShowSettingsWindowCommand}" />
                    <MenuItem Header="Bezárás" />
                </MenuItem>
            </Menu>
            <StackPanel Orientation="Horizontal" Grid.Row="1"  >
                <TextBlock Text="Keresés:" VerticalAlignment="Center" Margin="4"  />
                <TextBox  Margin="4" Width="400" Text="{Binding Source={StaticResource Locator}, Path=Main.SearchString , UpdateSourceTrigger=PropertyChanged}">
                    <i:Interaction.Triggers>
                        <i:EventTrigger EventName="KeyUp">
                            <cmd:EventToCommand Command="{Binding Source={StaticResource Locator}, Path=Main.SearchFileWithKeyCommand}" PassEventArgsToCommand="True" />
                        </i:EventTrigger>
                    </i:Interaction.Triggers>
                </TextBox>
                <Button ToolTip="Keres" Margin="4" Command="{Binding Source={StaticResource Locator}, Path=Main.SearchFileCommand}">
                    <Image Source="/XEasyFileSearch;component/Images/search2.png" />
                </Button>
            </StackPanel>
           
           
            <TextBlock Grid.Row="3"  />
            <ListBox Grid.Row="2" ItemsSource="{Binding Source={StaticResource Locator}, Path=Main.SearchResults}" 
                     SelectionMode="Single" SelectedItem="{Binding Source={StaticResource Locator}, Path=Main.SelectedSearchResult, Mode=TwoWay}">
                <i:Interaction.Triggers>
                    <i:EventTrigger EventName="MouseDoubleClick">
                        <cmd:EventToCommand Command="{Binding Source={StaticResource Locator}, Path=Main.OpenFileCommand}" />
                    </i:EventTrigger>
                </i:Interaction.Triggers>
                <ListBox.ItemTemplate>
                    <DataTemplate>
                        <StackPanel Orientation="Horizontal" >
                            <!--<Image Height="30" Source="{Binding Extension, Converter={StaticResource _IconDisplayConverter}}" />-->
                            <TextBlock Margin="2" Text="{Binding Name}" VerticalAlignment="Center"  />
                        </StackPanel>
                    </DataTemplate>
                </ListBox.ItemTemplate>
            </ListBox>
        </Grid>

    </xctk:BusyIndicator>

</Window>
